package com.example.graduationprojectweb.common;

import lombok.Data;

import java.io.Serializable;

@Data
public class ResponseEntity<T> implements Serializable {
    protected T result;
    protected int retCode = 200;
    protected String message = "ok";

    public ResponseEntity() {
    }

    public ResponseEntity(T t) {
        this.result = t;
    }

    public ResponseEntity(int code, String msg) {
        this.retCode = code;
        this.message = msg;
    }

    public static ResponseEntity ok() {
        return new ResponseEntity();
    }

    public static ResponseEntity ok(Object t) {
        return new ResponseEntity(t);
    }

    public static ResponseEntity error(String message) {
        return new ResponseEntity(500, message);
    }

    public Boolean checkSuccess() {
        return retCode == 200;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public int getRetCode() {
        return retCode;
    }

    public void setRetCode(int retCode) {
        this.retCode = retCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
